package com.boot.json;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 定制JSON转换器
 * @date 2019/11/11 12:22
 **/

@Slf4j
@Configuration
public class JacksonAutoConfiguration {

    @ConditionalOnMissingBean(value = ObjectMapper.class)
    @Bean
    public ObjectMapper createObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper instance = JacksonTool.getInstance();
        builder.configure(instance);
        return instance;
    }

}
